# -*- coding: utf-8 -*-
# @Time : 2021/12/22 17:02
# @Author : Limusen
# @File : demo_ui_operation

import time
from selenium import webdriver

# 识别元素进阶
driver = webdriver.Chrome()
driver.get("https://www.baidu.com")

# # 1.获取文本元素信息 获取新闻
# title = driver.find_element_by_xpath("//body[1]/div[1]/div[1]/div[3]/a[1]").text
# print(title)
#
# # 2.获取元素属性 获取百度一下的属性
# attribute = driver.find_element_by_css_selector("input#su").get_attribute('value')
# print(attribute)

# # 3.输入
# driver.find_element_by_css_selector("input#kw").send_keys("测试一下输入")
# time.sleep(2)
# # 4.清除输入框内容
# driver.find_element_by_css_selector("input#kw").clear()
# time.sleep(2)

# # 5.判断元素是否可见 如果元素可见则返回true
# display = driver.find_element_by_css_selector('input#kw').is_displayed()
# print(display)

# #　6.判断元素是否被禁用 如果元素没有被禁用则返回true
# enable = driver.find_element_by_css_selector('input#kw').is_enabled()
# print(enable)

# #　7.判断元素是否被选中 如果元素没有被选中则返回true
# selected = driver.find_element_by_css_selector('input#kw').is_selected()
# print(selected)

# # 8.获取对象的标签名称
# tag_name = driver.find_element_by_css_selector('input#kw').tag_name
# print(tag_name)

# # 9.获取元素坐标
# location = driver.find_element_by_css_selector('input#kw').location
# print(location)


driver.quit()
